package com.tw.trips.ui;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.stereotype.Service;

import com.tw.trips.domain.Update;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;

@Service
@Configurable(preConstruction = true)
public class LocationSearchPanel extends Panel {
	Window subwindow;
	HorizontalSplitPanel subPanel;
	TextField locationName;
	
	
	public LocationSearchPanel() {
		super();
		// TODO Auto-generated constructor stub
	}


	public LocationSearchPanel(HorizontalSplitPanel subHorzSplitPanel) {
		subPanel = subHorzSplitPanel;
		setHeight("100%");
		setWidth("100%");
		setCaption("Updates For?");
		
		VerticalLayout vertLayout = new VerticalLayout();
		locationName = new TextField("Search For:");
		vertLayout.addComponent(locationName);
		vertLayout.addComponent(includeSearchButton());
		addComponent(vertLayout);
	}
	
	
	private Component includeSearchButton() {
		// Button w/ text and tooltip
        Button addCommentButton = new Button("Search");
        
        addCommentButton.setDescription("Search");
        addCommentButton.addListener(new ClickListener() {
			
			public void buttonClick(ClickEvent event) {
				
				String location = (String) locationName.getValue();
				
				
			}
		}); 
        
        return addCommentButton;
	}
}
